package com.ruyuan.o2o.groupbuy.account.admin.controller;

import com.ruyuan.o2o.groupbuy.account.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.*;


/**
 * 商户登录
 *
 * @author ming qian
 */
@RestController
@RequestMapping("/auth")
@Log4j2
@Api(tags = "商户登录")
public class ShopLoginController {

    private final LoginService loginService;

    public ShopLoginController(LoginService loginService) {
        this.loginService = loginService;
    }

    /**
     * 商户登录接口
     *
     * @param adminName 账号
     * @param passwd    密码
     * @return 登录结果
     */
    @PostMapping("/login")
    @ApiOperation("商户登录")
    public String shopLogin(String adminName, String passwd) {
        log.info("{} # 商户登录 开始", adminName);

        if (!loginService.login(adminName, passwd)) {
            log.info("{} # 商户登录 失败", adminName);
            return "fail";
        }

        log.info("{} # 商户登录 成功", adminName);
        return "success";
    }

}
